package com.design.pattern.pa1.FactoryPattern;

public class FactoryPatternDemo {

    public static void main(String[] args) {

        String circle = ShapeType.CIRCLE.getMessage();
        String rectangle = ShapeType.RECTANGLE.getMessage();
        String square = ShapeType.SQUARE.getMessage();


        ShapeFactory shapeFactory = new ShapeFactory();
                //获取 Circle 的对象，并调用它的 draw 方法
        Shape shape1 = shapeFactory.getShape(circle);

        //调用 Circle 的 draw 方法
        shape1.draw();

        //获取 Rectangle 的对象，并调用它的 draw 方法
        Shape shape2 = shapeFactory.getShape(rectangle);

        //调用 Rectangle 的 draw 方法
        shape2.draw();

        //获取 Square 的对象，并调用它的 draw 方法
        Shape shape3 = shapeFactory.getShape(square);

        //调用 Square 的 draw 方法
        shape3.draw();
    }
}


enum ShapeType {
    CIRCLE("CIRCLE"),
    RECTANGLE("RECTANGLE"),
    SQUARE("SQUARE");
    final String message;

    ShapeType(String message) {
        this.message = message;
    }
    public String getMessage() {
        return message;
    }
}